import * as R from "ramda";
import axios from "axios"
function pipe() {
  return async function (ctx: Record<string, any>, next: Function) {
    return new Promise((resolve, reject) => {
      console.group(`RequestProcess:\n${ctx.name}`);
      console.log(`REQUEST:\n`, ctx.axios)
      axios.request(ctx.axios).then(res => {
        console.log(`RESPONSE:\n`, res)
        console.groupEnd();
        ctx.response = res;
        resolve(true);
      }).catch(err => {
        console.log(`ERROR:\n`, err.response)
        console.groupEnd();
        ctx.response = err.response;
        reject(ctx.response || { data: { msg: '服务器无响应，请确保已联网!' } });
      })
    })
    // await next()
  }
}
export default pipe;